package base.thread.pools;

import java.util.concurrent.BlockingQueue;

public class MyWorkerThread extends Thread {
    public BlockingQueue<Runnable> queue = null;

    public MyWorkerThread(BlockingQueue<Runnable> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        //工作线程的具体逻辑
        //需要从阻塞队列中取任务.
        while (true) {
            try {
                Runnable command = queue.take();
                //通过run来执行具体任务
                command.run();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
